var Fly=require("flyio/dist/npm/wx"); 
var request = true
var fly=new Fly;
//设置超时
fly.config.timeout=3000;
//设置请求基地址
fly.config.baseURL="http://pdd.xuhuinet.com/api/"
let flyio = {};
fly.interceptors.request.use((request)=>{
    let token = uni.getStorageSync('token');
	if(token) {
		request.headers["token"] = token;
	}
    return request;
})
fly.interceptors.response.use(
    (response) => {
		if(response.data.code == 0) {
			return response.data
		} else if(response.data.code == -3){
			console.log(response.data.msg);
			//  uni.showToast({
			// 	title: response.data.msg,
			// 	// icon:close,
			// 	success:function(){
			// 		uni.navigateTo({
			// 			url:"pages/index/login"
			// 		})
			// 	}
				
			// })
			
			return
		} else if(response.data.code == -1) {
			console.log(-1)
		}
        //只将请求结果的data字段返回
        return response.data
    },
    (err) => {
        return
    }
) 

flyio.get = (url , params)=>{
	return fly.get(url, params);
}
flyio.post = (url , params)=>{
	return fly.post(url, params);
}
export default fly